//===============================================================
// File		:	CD3DWrapper.h
//
// Purpose	:	Handles creation of our D3D device and
//				encapsulates important D3D methods.
//
// Author	: 	Michael Pedro
//
// Date		: 	4/13/2009
//===============================================================

#ifndef CD3DWrapper_H
#define CD3DWrapper_H

#include "d3d9.h"
#include "d3dx9.h"

// include libraries
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")
#pragma comment (lib, "dxguid.lib")

class CD3DWrapper
{
	IDirect3D9* 		m_pD3D;			// Pointer to our D3D interface
	IDirect3DDevice9*	m_pD3DDevice;	// Pointer to our D3D Device
	
protected:

	// We are creating a singleton so lets make sure no one trys to
	// use these methods.
	CD3DWrapper(const CD3DWrapper& ref) {}
	CD3DWrapper& operator=(const CD3DWrapper& ref) {}	
	CD3DWrapper();
	~CD3DWrapper();
	
public:

	//===========================================================
	// Method	:	GetInstance()
	// Purpose	:	Return the single instance of our D3DWrapper
	// Return	:	Our single instance
	//===========================================================
	static CD3DWrapper* GetInstance(void);
	
	//===========================================================
	// Method	:	InitializeD3D()
	// Purpose	:	Attempt to initialize Direct3D
	//
	// In		:	hWnd - Handle to our window
	//				nScreenWidth - Width of our screen
	//				nScreenHeight - Height of our screen
	//              bWindowed - false for Fullscreen mode
	//
	// Return	:	Return true if successful
	//===========================================================
	bool InitializeD3D(HWND hWnd, int nScreenWidth, int nScreenHeight, bool bWindowed);
	
	//===========================================================
	// Method	:	Present()
	// Purpose	:	Present the back buffer
	//===========================================================
	void Present(void) { m_pD3DDevice->Present(0,0,0,0); }
	
	//===========================================================
	// Method	:	Clear()
	// Purpose	:	Clear the screen to a specified color
	//
	// In		:	RGB colors for the screen
	//===========================================================
	void Clear(unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue);
	
	// Accessors
	IDirect3DDevice9* GetDevice(void) const { return m_pD3DDevice; }
};

#endif
